<template>

<!-- 商品信息详情 -->
<el-card >
  <div style="float: left;">
      <img :src="model.gImg" width="120" height="120"/>
  </div>
  <div style="margin-left: 40px;float: left;margin-bottom: 20px;">
      <h2 style="margin-bottom: 10px;font-weight: bold" >{{ model.nName }}</h2>
     <h5 style="margin-right: 250px;">生产批次: {{ model.gBatch }} </h5>  
     <h5 style="">保质期: {{ model.gDay }}天 </h5>  
     
     <h5 style="margin-right: 130px;">生产许可证号: {{ model.gGeneration }} </h5>  
     <h5 style="">生产企业: {{ model.gCompany }} </h5> 
     
  </div>
  <div style="float: left;">
    <h3 style="font-weight: bold">产品检验报告</h3>
     <div style="margin-top: 10px;">
        <div style="float: left;">
          <img :src="i" style="width: 80px;height: 80px;margin-left: 10px;" v-for="i in model.productImg.split(',')" />
           </div>  
           <div style="float: left;margin-left: 10px;">
           <el-upload
              v-model:file-list="fileList"
              action="http://localhost:5028/api/Student/Upload"
              list-type="picture-card"
              :on-preview="handlePictureCardPreview"
              :on-remove="handleRemove"
            >
              <el-icon><Plus /></el-icon>
            </el-upload>
        
        
            <el-dialog v-model="dialogVisible" >
              <img w-full  alt="Preview Image" style="width: 80px;height: 80px;" />
            </el-dialog>
           
           </div>  
        </div>
  </div>
  <div style="float: right;">
        <el-button type="primary"  @click="">编辑</el-button>
        <el-button type="success"  @click="">详情</el-button>
        <el-button type="info"   @click="">导出溯源码</el-button>
    </div>
</el-card>

<!-- 菜单 -->
<el-card style="margin-top: 20px;height: 2700px;">
    <el-tabs
        v-model="activeName"
        type="card"
        class="demo-tabs"
        @tab-click="handleClick"
      >
        <el-tab-pane label="养殖信息(5/5)" name="first">
          
          <!-- 养殖信息 -->
          <div class="info-header">
            <span class="info-title" style="color:lightskyblue;">养殖信息</span>
            <el-button style="margin-left: 5px;" @click="openbreed()" size="small">设置</el-button>
          </div> <el-divider />
          <el-table :data="BreedtableData" style="width: 100%;height: 120px;">
             <el-table-column type="index" label="序号" width="55" />
            <el-table-column prop="breedVariety" label="品种"  />
            <el-table-column prop="breedRaise" label="来源" />
            <el-table-column prop="raiseDay" label="饲养天数(天)" />
            <el-table-column prop="raiseBrand" label="饲养品牌" />
            <el-table-column prop="breedRaiser" label="饲养负责人" />
            <el-table-column prop="endTime" label="栏日期" >
              <template #default="scope">
                  {{ moment(scope.row.endTime).format("YYYY年MM月DD日") }}
              </template>
            </el-table-column>
             <el-table-column  label="操作" >
              <template #default="scope">
                  <el-button link  type="warning" @click="openbreed(scope.row)" >编辑</el-button>
              </template>
            </el-table-column>
          </el-table>

          <!-- 免疫信息 -->
          <div class="info-header" style="margin-top: 20px;">
            <span class="info-title" style="color:lightskyblue;">免疫信息</span>
            <el-button style="margin-left: 5px;" @click="createimmunity()" size="small">新增行</el-button>
          </div> <el-divider />
          <el-table :data="ImmunitytableData" style="width: 100%;height: 120px;">
             <el-table-column type="index" label="序号" width="55" />
            <el-table-column prop="raiseDay" label="饲养天数" >
              <template #default="scope">
                  <el-input v-model="scope.row.raiseDay" style="width: 180px;" v-if="scope.row.immunityId==null "/>
                  <span v-if="scope.row.immunityId!=null ">{{ scope.row.raiseDay }}</span>
              </template>
            </el-table-column>
            <el-table-column prop="immunityType" label="免疫方式" >
              <template #default="scope">
                  <el-input v-model="scope.row.immunityType" style="width: 180px;" v-if="scope.row.immunityId==null"/>
                  <span v-if="scope.row.immunityId!=null">{{ scope.row.immunityType }}</span>
              </template>
            </el-table-column>
            <el-table-column prop="immunityMethod" label="免疫方法" >
              <template #default="scope">
                  <el-input v-model="scope.row.immunityMethod" style="width: 180px;" v-if="scope.row.immunityId==null"/>
                  <span v-if="scope.row.immunityId!=null">{{ scope.row.immunityMethod }}</span>
              </template>
            </el-table-column>
           
             <el-table-column  label="操作" >
              <template #default="scope">
                  <el-button type="warning" @click="openimmunity(scope.row)" link v-if="scope.row.immunityId!=null" >编辑</el-button>
                  <el-button type="danger" @click="deleteImmunity(scope.row.immunityId)"  link v-if="scope.row.immunityId!=null" >删除</el-button>
                  <el-button type="warning" @click="saveImmunity(scope.row)" link v-if="scope.row.immunityId==null" >保存</el-button>
                  <el-button type="danger" @click="removeimmunity(scope.$index)"  link v-if="scope.row.immunityId==null" >取消</el-button>
              </template>
            </el-table-column>
          </el-table>

           <!-- 动检证 -->
          <div class="info-header" style="margin-top: 20px;">
            <span class="info-title" style="color:lightskyblue;">动检证</span>
          </div> <el-divider />
          <div style="margin-top: 10px;">
            <div style="float: left;">
              <img :src="i.quarantineImg" width="100" height="100" v-for="i in enterprisizelistpic" style="margin-right: 10px;"/>
            </div>
            <div style="margin-left: 20px;">
              <el-upload
                class="avatar-uploader"
                action="http://localhost:5028/api/Student/Upload"
                :show-file-list="false"
                :on-success="handleAvatarSuccess"
                :before-upload="beforeAvatarUpload"
              >
                <img v-if="enterprisepicform.quarantineImg" :src="enterprisepicform.quarantineImg" class="avatar" width="100" height="100"/>
                <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
              </el-upload>
            </div>
              
          </div>
          
         
          <!-- 企业信息 -->
           
          <div class="info-header" style="margin-top: 20px;">
            <span class="info-title" style="color:lightskyblue;">企业信息</span>
            <el-button style="margin-left: 5px;" @click="enterpriselogic.isopen=true" size="small">设置</el-button>
          </div> <el-divider />
          <div>
              <el-table :data="enterprisizelist" style="width: 100%;height: 120px;">
                <el-table-column type="index" label="序号" width="55" />
                <el-table-column prop="enterpriseFarm" label="养殖场"  />
                <el-table-column prop="enterprisePerson" label="负责人" />
                <el-table-column prop="inventotyNumber" label="存栏数量" />
              </el-table>
          </div>

          <!-- 公司照片 -->
          <div class="info-header" style="margin-top: 20px;">
            <span class="info-title" style="color:lightskyblue;">企业照片</span>
          </div> <el-divider />
          <div style="margin-top: 10px;">
            <div style="float: left;">
              <img :src="i.enterprisePicName" width="100" height="100" v-for="i in quarantinelistpic" style="margin-right: 10px;"/>
            </div>
            <div style="margin-left: 20px;">
              <el-upload
                class="avatar-uploader"
                action="http://localhost:5028/api/Student/Upload"
                :show-file-list="false"
                :on-success="handleAvatarSuccessquarantine"
                :before-upload="beforeAvatarUpload"
              >
                <img v-if="quarantineform.enterprisePicName" :src="quarantineform.enterprisePicName" class="avatar" width="100" height="100"/>
                <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
              </el-upload>
            </div>
              
          </div>
          

        </el-tab-pane>
        <el-tab-pane label="屠宰信息(5/5)" name="second">
           <!-- 屠宰信息 -->
          <div class="info-header">
            <span class="info-title" style="color:lightskyblue;">养殖信息</span>
            <el-button style="margin-left: 5px;" @click="slautherlogic.isopen=true" size="small">设置</el-button>
          </div> <el-divider />
          <el-table :data="Slaughterlist" style="width: 100%;height: 120px;">
             <el-table-column type="index" label="序号" width="55" />
            <el-table-column prop="slaughterbatch" label="批次"  />
            <el-table-column prop="slaughterweight" label="到厂均重" />
            <el-table-column prop="arrivateTime" label="到厂时间" >
               <template #default="scope">
                  {{ moment(scope.row.arrivateTime).format("YYYY年MM月DD日 HH:mm:sss") }}
              </template>
            </el-table-column>
            <el-table-column prop="slaughterTime" label="屠宰时间" >
               <template #default="scope">
                  {{ moment(scope.row.slaughterTime).format("YYYY年MM月DD日 HH:mm:sss") }}
              </template>
            </el-table-column>
          </el-table>

           <!-- 相关资质 -->
          <div class="info-header" style="margin-top: 20px;">
            <span class="info-title" style="color:lightskyblue;">相关资质</span>
          </div> <el-divider />
          <div style="margin-top: 10px;">
            <div style="float: left;">
              <img :src="i.qualificationImg" width="100" height="100" v-for="i in qualificationlist" style="margin-right: 10px;"/>
            </div>
            <div style="margin-left: 20px;">
              <el-upload
                class="avatar-uploader"
                action="http://localhost:5028/api/Student/Upload"
                :show-file-list="false"
                :on-success="handleAvatarSuccessqualification"
                :before-upload="beforeAvatarUpload"
              >
                <img v-if="qualificationform.qualificationImg" :src="qualificationform.qualificationImg" class="avatar" width="100" height="100"/>
                <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
              </el-upload>
            </div>
              
          </div>
          <br/><!-- 相关资质加了浮动会影响企业信息布局 -->
           <!-- 企业信息 -->
          <div class="info-header">
            <span class="info-title" style="color:lightskyblue;">企业信息</span>
            <el-button style="margin-left: 5px;" @click="opencommpany()" size="small">设置</el-button>
          </div> <el-divider />
          <el-table :data="commpanylist" style="width: 100%;height: 120px;">
             <el-table-column type="index" label="序号" width="55" />
            <el-table-column prop="commpanyName" label="公司名称"  />
            <el-table-column prop="addressName" label="公司地址" />
            <el-table-column prop="createTime" label="成立时间" >
              <template #default="scope">
                  {{ moment(scope.row.endTime).format("YYYY年MM月DD日") }}
              </template>
            </el-table-column>
            <el-table-column prop="commpanyDesc" label="公司简介" />
            <el-table-column  label="操作" >
              <template #default="scope">
                  <el-button link  type="warning" @click="opencommpany(scope.row)" >编辑</el-button>
              </template>
            </el-table-column>
          </el-table>

           <!-- 企业照片 -->
          <div class="info-header" style="margin-top: 20px;">
            <span class="info-title" style="color:lightskyblue;">企业照片</span>
          </div> <el-divider />
          <div style="margin-top: 10px;">
            <div style="float: left;">
              <img :src="i.commpanyPIcName" width="100" height="100" v-for="i in commpanypiclist" style="margin-right: 10px;"/>
            </div>
            <div style="margin-left: 20px;">
              <el-upload
                class="avatar-uploader"
                action="http://localhost:5028/api/Student/Upload"
                :show-file-list="false"
                :on-success="handleAvatarSuccesscommpanypic"
                :before-upload="beforeAvatarUpload"
              >
                <img v-if="commpanypicform.commpanyPIcName" :src="commpanypicform.commpanyPIcName"  width="100" height="100"/>
                <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
              </el-upload>
            </div>
              
          </div>
           
            
        </el-tab-pane>
        <el-tab-pane label="深加工信息(5/5)" name="third">
          <!-- 深加工信息 -->
        <div class="info-header">
          <span class="info-title" style="color:lightskyblue;">深加工信息</span>
          <el-button style="margin-left: 5px;" @click="deeplogic.isopen=true" size="small">设置</el-button>
        </div> <el-divider />
        <el-table :data="deeplist" style="width: 100%;height: 120px;">
            <el-table-column type="index" label="序号" width="80" />
          <el-table-column prop="deepClass" label="班组"  />
          <el-table-column prop="deepPerson" label="负责人" />
        </el-table>
           <!-- 食品安全信息 -->
          <div class="info-header" style="margin-top: 20px;">
            <span class="info-title" style="color:lightskyblue;">食品安全信息</span>
          </div> <el-divider />
          <div style="margin-top: 10px;">
            <div style="float: left;">
              <img :src="i.foodSafetyImg" width="100" height="100" v-for="i in deepppiclist" style="margin-right: 10px;"/>
            </div>
            <div style="margin-left: 20px;">
              <el-upload
                class="avatar-uploader"
                action="http://localhost:5028/api/Student/Upload"
                :show-file-list="false"
                :on-success="handleAvatarSuccessdeeppic"
                :before-upload="beforeAvatarUpload"
              >
                <img v-if="deeppicform.foodSafetyImg" :src="deeppicform.foodSafetyImg" class="avatar" width="100" height="100"/>
                <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
              </el-upload>
            </div>
              
          </div>
          <br/><!-- 上面加了浮动会影响下面信息布局 -->
            <!-- 供应商信息 -->
          <div class="info-header" style="margin-bottom: 10px;">
            <span class="info-title" style="color:lightskyblue;font-size: 18px;">供应商信息</span>
          </div> <el-divider />

          <!-- 原料 -->
          <div class="info-header">
            <span class="info-title" style="font-weight: bold;">原料</span>
            <el-button style="margin-left: 15px;" @click="Feedstocklogic.isopen=true" size="small">设置</el-button>
          </div> <el-divider />
          <el-table :data="Feedstocklist" style="width: 100%;height: 120px;">
            <el-table-column type="index" label="序号" width="80" />
            <el-table-column prop="feedstockBath" label="生产批次"  />
          </el-table>

          <!-- 原料图片 -->
           <div class="info-header" style="margin-top: 20px;">
            <span class="info-title" style="font-weight: bold;">相关材料</span>
          </div> <el-divider />
          <div style="margin-top: 10px;">
            <div style="float: left;">
              <img :src="i.feedstockImg" width="100" height="100" v-for="i in Feedstockpiclist" style="margin-right: 10px;"/>
            </div>
            <div style="margin-left: 20px;">
              <el-upload
                class="avatar-uploader"
                action="http://localhost:5028/api/Student/Upload"
                :show-file-list="false"
                :on-success="handleAvatarSuccessFeedstockpic"
                :before-upload="beforeAvatarUpload"
              >
                <img v-if="Feedstockpicform.feedstockImg" :src="Feedstockpicform.feedstockImg" class="avatar" width="100" height="100"/>
                <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
              </el-upload>
            </div>
              
          </div>
          <br/><!-- 上面加了浮动会影响下面信息布局 -->

           <!-- 辅料 -->
          <div class="info-header">
            <span class="info-title" style="font-weight: bold;">辅料</span>
            <el-button style="margin-left: 15px;" @click="Additivelogic.isopen=true" size="small">设置</el-button>
          </div> <el-divider />
          <el-table :data="Additivelist" style="width: 100%;height: 120px;">
            <el-table-column type="index" label="序号" width="80" />
            <el-table-column prop="additiveBath" label="生产批次"  />
          </el-table>

          <!-- 辅料图片 -->
           <div class="info-header" style="margin-top: 20px;">
            <span class="info-title" style="font-weight: bold;">相关材料</span>
          </div> <el-divider />
          <div style="margin-top: 10px;">
            <div style="float: left;">
              <img :src="i.additiveImg" width="100" height="100" v-for="i in Additivepiclist" style="margin-right: 10px;"/>
            </div>
            <div style="margin-left: 20px;">
              <el-upload
                class="avatar-uploader"
                action="http://localhost:5028/api/Student/Upload"
                :show-file-list="false"
                :on-success="handleAvatarSuccessAdditivepic"
                :before-upload="beforeAvatarUpload"
              >
                <img v-if="Additivepicform.additiveImg" :src="Additivepicform.additiveImg" class="avatar" width="100" height="100"/>
                <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
              </el-upload>
            </div>
              
          </div>
          <br/><!-- 上面加了浮动会影响下面信息布局 -->

          <!-- 添加剂 -->
          <div class="info-header">
            <span class="info-title" style="font-weight: bold;">添加剂</span>
            <el-button style="margin-left: 15px;" @click="Materiallogic.isopen=true" size="small">设置</el-button>
          </div> <el-divider />
          <el-table :data="Materiallist" style="width: 100%;height: 120px;">
            <el-table-column type="index" label="序号" width="80" />
            <el-table-column prop="materialBath" label="生产批次"  />
          </el-table>

          <!-- 添加剂图片 -->
           <div class="info-header" style="margin-top: 20px;">
            <span class="info-title" style="font-weight: bold;">相关材料</span>
          </div> <el-divider />
          <div style="margin-top: 10px;">
            <div style="float: left;">
              <img :src="i.materialImg" width="100" height="100" v-for="i in Materialpiclist" style="margin-right: 10px;"/>
            </div>
            <div style="margin-left: 20px;">
              <el-upload
                class="avatar-uploader"
                action="http://localhost:5028/api/Student/Upload"
                :show-file-list="false"
                :on-success="handleAvatarSuccessMaterialpic"
                :before-upload="beforeAvatarUpload" 
              >
                <img v-if="Materialpicform.materialImg" :src="Materialpicform.materialImg" class="avatar" width="100" height="100"/>
                <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
              </el-upload>
            </div>
              
          </div>
          <br/><!-- 上面加了浮动会影响下面信息布局 -->

           <!-- 包材 -->
          <div class="info-header">
            <span class="info-title" style="font-weight: bold;font-size: 15px;">包材</span>
            <el-button style="margin-left: 15px;" @click="Packaginglogic.isopen=true" size="small">设置</el-button>
          </div> <el-divider />
          <el-table :data="Packaginglist" style="width: 100%;height: 120px;">
            <el-table-column type="index" label="序号" width="80" />
            <el-table-column prop="packagingBath" label="生产批次"  />
          </el-table>

          <!-- 包材图片 -->
           <div class="info-header" style="margin-top: 20px;">
            <span class="info-title" style="font-weight: bold;">相关材料</span>
          </div> <el-divider />
          <div style="margin-top: 10px;">
            <div style="float: left;">
              <img :src="i.packagingImg" width="100" height="100" v-for="i in Packagingpiclist" style="margin-right: 10px;"/>
            </div>
            <div style="margin-left: 20px;">
              <el-upload
                class="avatar-uploader"
                action="http://localhost:5028/api/Student/Upload"
                :show-file-list="false"
                :on-success="handleAvatarSuccessPackagingpic"
                :before-upload="beforeAvatarUpload" 
              >
                <img v-if="Packagingpicform.packagingImg" :src="Packagingpicform.packagingImg" class="avatar" width="100" height="100"/>
                <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
              </el-upload>
            </div>
              
          </div>
          <br/><!-- 上面加了浮动会影响下面信息布局 -->

            <!-- 企业信息 -->
          <div class="info-header">
            <span class="info-title" style="color:lightskyblue;">企业信息</span>
            <el-button style="margin-left: 5px;" @click="ProcessingCommpanylogic.isopen=true" size="small">设置</el-button>
          </div> <el-divider />
          <el-table :data="ProcessingCommpanylist" style="width: 100%;height: 120px;">
             <el-table-column type="index" label="序号" width="55" />
            <el-table-column prop="proComName" label="公司名称"  />
            <el-table-column prop="proComBath" label="生产许可证号" />
          </el-table>

           <!-- 企业照片 -->
          <div class="info-header" style="margin-top: 20px;">
            <span class="info-title" style="color:lightskyblue;">企业照片</span>
          </div> <el-divider />
          <div style="margin-top: 10px;">
            <div style="float: left;">
              <img :src="i.processingImg" width="100" height="100" v-for="i in Processingpiclist" style="margin-right: 10px;"/>
            </div>
            <div style="margin-left: 20px;">
              <el-upload
                class="avatar-uploader"
                action="http://localhost:5028/api/Student/Upload"
                :show-file-list="false"
                :on-success="handleAvatarSuccessProcessingpic"
                :before-upload="beforeAvatarUpload"
              >
                <img v-if="Processingpicform.processingImg" :src="Processingpicform.processingImg"  width="100" height="100"/>
                <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
              </el-upload>
            </div>
              
          </div>

        </el-tab-pane>
      </el-tabs>
</el-card >


 <!-- 养殖信息弹框新增   -->
  <el-dialog v-model="breedlogic.isopen" title="养殖信息" width="700">
    <el-form style="width: 400px;">
      
      <el-form-item label="品种:">
        <el-input v-model="Breedform.breedVariety"  />
      </el-form-item>

      <el-form-item label="来源:">
        <el-input v-model="Breedform.breedRaise"  />
      </el-form-item>

      <el-form-item label="饲养天数(天):">
        <el-input v-model="Breedform.raiseDay"  />
      </el-form-item>

      <el-form-item label="饲养品牌:">
        <el-input v-model="Breedform.raiseBrand"  />
      </el-form-item>

      <el-form-item label="饲养负责人:">
        <el-input v-model="Breedform.breedRaiser"  />
      </el-form-item>

      <el-form-item label="栏日期:">
        <el-input type="date" v-model="Breedform.endTime"  />
      </el-form-item>
      
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="breedlogic.isopen = false" >取消</el-button>
        <el-button type="primary" @click="savebreed()" >
          保存
        </el-button>
      </div>
    </template>
  </el-dialog>

  <!-- 养殖免疫弹框 -->
  <el-dialog v-model="logicImmunity.isopen" title="养殖信息" width="700">
    <el-form style="width: 400px;">
      
      <el-form-item label="饲养天数:">
        <el-input v-model="ImmunityForm.raiseDay"  />
      </el-form-item>

      <el-form-item label="免疫方式:">
        <el-input v-model="ImmunityForm.immunityType"  />
      </el-form-item>

      <el-form-item label="免疫方法:">
        <el-input v-model="ImmunityForm.immunityMethod"  />
      </el-form-item>
      
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="logicImmunity.isopen = false" >取消</el-button>
        <el-button type="primary" @click="updateImmunity()" >
          保存
        </el-button>
      </div>
    </template>
  </el-dialog>
    <!-- 养殖企业弹框 -->
  <el-dialog v-model="enterpriselogic.isopen" title="企业信息" width="500">
    <el-form style="width: 400px;">
      
      <el-form-item label="养殖场:">
        <el-input v-model="enterpriseform.enterpriseFarm"  />
      </el-form-item>

      <el-form-item label="负责人:">
        <el-input v-model="enterpriseform.enterprisePerson"  />
      </el-form-item>

      <el-form-item label="存栏数量:">
        <el-input v-model="enterpriseform.inventotyNumber"  />
      </el-form-item>
      
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="enterpriselogic.isopen = false" >取消</el-button>
        <el-button type="primary" @click="saveEnterprise" >
          保存
        </el-button>
      </div>
    </template>
  </el-dialog>

   <!-- 屠宰弹框 -->
  <el-dialog v-model="slautherlogic.isopen" title="屠宰信息" width="500">
    <el-form style="width: 400px;">
      
      <el-form-item label="批次:">
        <el-input v-model="slauhterform.slaughterbatch"  />
      </el-form-item>

      <el-form-item label="到厂均重:">
        <el-input v-model="slauhterform.slaughterweight"  />
      </el-form-item>

      <el-form-item label="到厂时间:">
        <el-input type="date" v-model="slauhterform.arrivateTime"  />
      </el-form-item>

      <el-form-item label="屠宰时间:">
        <el-input type="date" v-model="slauhterform.slaughterTime"  />
      </el-form-item>
      
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="slautherlogic.isopen = false" >取消</el-button>
        <el-button type="primary" @click="createslauther" >
          保存
        </el-button>
      </div>
    </template>
  </el-dialog>
  <!-- 屠宰企业弹框 -->
  <el-dialog v-model="commpanylogic.isopen" title="企业信息" width="500">
    <el-form style="width: 400px;">
      <el-form-item label="公司名称:">
        <el-input v-model="commpanyform.commpanyName"  />
      </el-form-item>

      <el-form-item label="公司地址:">
        <el-select style="width: 100px;" placeholder="省" v-model="cityform.ProvincialId" @change="getcity(),commpanyform.commpanyAddress=null">
          <el-option v-for="i in provinciallist" :label="i.provincialName" :value="i.provincialId" />
        </el-select>
        <el-select style="width: 100px;margin-left: 10px;" placeholder="市" v-model="cityform.CityId" @change="getprovincial(),commpanyform.commpanyAddress=null,cityform.CityId=null">
          <el-option v-for="i in citylist" :label="i.cityName" :value="i.cityId" />
        </el-select>
        <el-select style="width: 100px;margin-left: 10px;" placeholder="县" v-model="commpanyform.commpanyAddress">
          <el-option v-for="i in addresslist" :label="i.addressName" :value="i.addressId" />
        </el-select>
      </el-form-item>

      <el-form-item label="成立时间:">
        <el-input type="date" v-model="commpanyform.createTime"  />
      </el-form-item>

      <el-form-item label="公司简介:">
        <el-input type="textarea" v-model="commpanyform.commpanyDesc"  />
      </el-form-item>
      
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="commpanylogic.isopen = false" >取消</el-button>
        <el-button type="primary" @click="savecommpany" >
          保存
        </el-button>
      </div>
    </template>
  </el-dialog>

    <!-- 深加工弹框 -->
  <el-dialog v-model="deeplogic.isopen" title="深加工信息" width="500">
    <el-form style="width: 400px;">
      <el-form-item label="班组:">
        <el-input v-model="deepform.deepClass"  />
      </el-form-item>

      <el-form-item label="负责人:">
        <el-input v-model="deepform.deepPerson"  />
      </el-form-item>
      
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="deeplogic.isopen = false" >取消</el-button>
        <el-button type="primary" @click="createdeep" >
          保存
        </el-button>
      </div>
    </template>
  </el-dialog>

    <!-- 深加工原料弹框 -->
  <el-dialog v-model="Feedstocklogic.isopen" title="原料信息" width="500">
    <el-form style="width: 400px;">
      <el-form-item label="生产批次:">
        <el-input v-model="Feedstockform.feedstockBath"  />
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="Feedstocklogic.isopen = false" >取消</el-button>
        <el-button type="primary" @click="createFeedstock" >
          保存
        </el-button>
      </div>
    </template>
  </el-dialog>

   <!-- 深加工辅料弹框 -->
  <el-dialog v-model="Additivelogic.isopen" title="辅料信息" width="500">
    <el-form style="width: 400px;">
      <el-form-item label="生产批次:">
        <el-input v-model="Additiveform.additiveBath"  />
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="Additivelogic.isopen = false" >取消</el-button>
        <el-button type="primary" @click="createAdditive" >
          保存
        </el-button>
      </div>
    </template>
  </el-dialog>

  <!-- 深加工添加剂弹框 -->
  <el-dialog v-model="Materiallogic.isopen" title="添加剂信息" width="500">
    <el-form style="width: 400px;">
      <el-form-item label="生产批次:">
        <el-input v-model="Materialform.materialBath"  />
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="Materiallogic.isopen = false" >取消</el-button>
        <el-button type="primary" @click="createMaterial" >
          保存
        </el-button>
      </div>
    </template>
  </el-dialog>

  <!-- 深加工包材弹框 -->
  <el-dialog v-model="Packaginglogic.isopen" title="包材信息" width="500">
    <el-form style="width: 400px;">
      <el-form-item label="生产批次:">
        <el-input v-model="Packagingform.packagingBath"  />
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="Packaginglogic.isopen = false" >取消</el-button>
        <el-button type="primary" @click="createPackaging" >
          保存
        </el-button>
      </div>
    </template>
  </el-dialog>

  <!-- 深加工企业弹框 -->
  <el-dialog v-model="ProcessingCommpanylogic.isopen" title="包材信息" width="500">
    <el-form style="width: 400px;">
      <el-form-item label="公司名称:">
        <el-input v-model="ProcessingCommpanyform.proComName"  />
      </el-form-item>
      <el-form-item label="生产许可证号:">
        <el-input v-model="ProcessingCommpanyform.proComBath"  />
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="ProcessingCommpanylogic.isopen = false" >取消</el-button>
        <el-button type="primary" @click="createProcessingCommpany" >
          保存
        </el-button>
      </div>
    </template>
  </el-dialog>



</template>
<script lang="ts" setup>
import { reactive,ref,onMounted,watch } from 'vue'
import { ElMessage,ElMessageBox } from 'element-plus'
import { useRoute,useRouter } from 'vue-router'
import moment from 'moment'
import axios from 'axios'
const route = useRoute()
const router = useRouter()
//商品详情数据
const model:any =ref({
  creator     : route.query.creator,
  createTime  : route.query.createTime,
  updater     : route.query.updater,
  updateTime  : route.query.updateTime,
  rId         : route.query.rId,
  nId         : route.query.nId,
  nName       : route.query.nName,
  gBatch      : route.query.gBatch,
  gDay        : route.query.gDay,
  gGeneration : route.query.gGeneration,
  gCompany    : route.query.gCompany,
  gInformation: route.query.gInformation,
  gImg        : route.query.gImg,
  productImg:route.query.productImg,
  isDelete    : route.query.isDelete,
})  


//------------------------------------------------------------包材------------------------------------------------------------
//#region
//-------------深加工包材----------------------------------------
//加深工包材图片上传
const handleAvatarSuccessProcessingpic=(imageUrl:any)=>{
  Processingpicform.processingImg=imageUrl;
  if(Processingpicform.processingImg==null)
  {
    ElMessage.error("请上传图片");
    return;
  }
  axios({
          url:"http://localhost:5028/api/Deep/CreateProcessingpic",
          method:"post",
          data:Processingpicform
      })
      .then(res=>{
          if(res.data.code==100)
          {
              getProcessingpic();
              ElMessage.success(res.data.message);
              Processingpicform.processingImg="";
          }
          else{
              ElMessage.error(res.data.message);
          }
      })
}
//深加工包材照片表单
const Processingpicform=reactive({
  "processingpicId": 0,
  "rId":  model.value.rId,
  "processingImg": ""
})

//深加工包材照片接收
const Processingpiclist=ref([{
  "processingpicId": 0,
  "rId":  model.value.rId,
  "processingImg": ""
}])
//深加工包材照片请求
const getProcessingpic=()=>{
    axios({
        url:"http://localhost:5028/api/Deep/GetProcessingpicAll",
        method:"get",
        params:{
            id:model.value.rId,
        }
    })
    .then(res=>{
        Processingpiclist.value=res.data.data;
    })
}

//深加工包材弹框
const ProcessingCommpanylogic= reactive({
  isopen:false,
})
//创建深加工包材请求
const createProcessingCommpany=()=>{
    axios({
        url:"http://localhost:5028/api/Deep/CreateProcessingCommpany",
        method:"post",
        data:ProcessingCommpanyform
    })
    .then(res=>{
        if(res.data.code==100)
          {
              getProcessingCommpany();
              ElMessage.success(res.data.message);
              ProcessingCommpanylogic.isopen=false;
          }
          else{
              ElMessage.error(res.data.message);
          }
    })
}
//深加工包材表单
const ProcessingCommpanyform = reactive({
  "proComId": 0,
  "rId": model.value.rId,
  "proComName": "",
  "proComBath": ""
})

//深加工包材请求
const getProcessingCommpany=()=>{
  axios({
        url:"http://localhost:5028/api/Deep/GetProcessingCommpanyAll",
        method:"get",
        params:{
            id:model.value.rId,
        }
    })
    .then(res=>{
        ProcessingCommpanylist.value=res.data.data;
    })
}
//深加包材料接收
const ProcessingCommpanylist=ref([{
  "proComId": 0,
  "rId": model.value.rId,
  "proComName": "",
  "proComBath": ""
}])
//#endregion
//------------------------------------------------------------深加工包材------------------------------------------------------------
//#region
//-------------深加工包材----------------------------------------
//加深工包材图片上传
const handleAvatarSuccessPackagingpic=(imageUrl:any)=>{
  Packagingpicform.packagingImg=imageUrl;
  if(Packagingpicform.packagingImg==null)
  {
    ElMessage.error("请上传图片");
    return;
  }
  axios({
          url:"http://localhost:5028/api/Deep/CreatePackagingpic",
          method:"post",
          data:Packagingpicform
      })
      .then(res=>{
          if(res.data.code==100)
          {
              getPackagingpic();
              ElMessage.success(res.data.message);
              Packagingpicform.packagingImg="";
          }
          else{
              ElMessage.error(res.data.message);
          }
      })
}
//深加工包材照片表单
const Packagingpicform=reactive({
  "packagingpicId": 0,
  "rId": model.value.rId,
  "packagingImg": ""
})

//深加工包材照片接收
const Packagingpiclist=ref([{
  "packagingpicId": 0,
  "rId": model.value.rId,
  "packagingImg": ""
}])
//深加工包材照片请求
const getPackagingpic=()=>{
    axios({
        url:"http://localhost:5028/api/Deep/GetPackagingpicAll",
        method:"get",
        params:{
            id:model.value.rId,
        }
    })
    .then(res=>{
        Packagingpiclist.value=res.data.data;
    })
}

//深加工包材弹框
const Packaginglogic= reactive({
  isopen:false,
})
//创建深加工包材请求
const createPackaging=()=>{
    axios({
        url:"http://localhost:5028/api/Deep/CreatePackaging",
        method:"post",
        data:Packagingform
    })
    .then(res=>{
        if(res.data.code==100)
          {
              getPackaging();
              ElMessage.success(res.data.message);
              Packaginglogic.isopen=false;
          }
          else{
              ElMessage.error(res.data.message);
          }
    })
}
//深加工包材表单
const Packagingform = reactive({
  "packagingId": 0,
  "rId": model.value.rId,
  "packagingBath": ""
})

//深加工包材请求
const getPackaging=()=>{
  axios({
        url:"http://localhost:5028/api/Deep/GetPackagingAll",
        method:"get",
        params:{
            id:model.value.rId,
        }
    })
    .then(res=>{
        Packaginglist.value=res.data.data;
    })
}
//深加包材料接收
const Packaginglist=ref([{
  "packagingId": 0,
  "rId": model.value.rId,
  "packagingBath": ""
}])
//#endregion
//------------------------------------------------------------深加工添加剂------------------------------------------------------------
//#region
//-------------深加工添加剂----------------------------------------
//深加工添加剂图片上传
const handleAvatarSuccessMaterialpic=(imageUrl:any)=>{
  Materialpicform.materialImg=imageUrl;
  if(Materialpicform.materialImg==null)
  {
    ElMessage.error("请上传图片");
    return;
  }
  axios({
          url:"http://localhost:5028/api/Deep/CreateMaterialpic",
          method:"post",
          data:Materialpicform
      })
      .then(res=>{
          if(res.data.code==100)
          {
              getMaterialpic();//食品安全图片请求
              ElMessage.success(res.data.message);
              Materialpicform.materialImg="";
          }
          else{
              ElMessage.error(res.data.message);
          }
      })
}
//深加工添加剂照片表单
const Materialpicform=reactive({
"materialpicId": 0,
  "rId": model.value.rId,
  "materialImg": ""
})

//深加工添加剂照片接收
const Materialpiclist=ref([{
 "materialpicId": 0,
  "rId": model.value.rId,
  "materialImg": "string"
}])
//深加工添加剂照片请求
const getMaterialpic=()=>{
    axios({
        url:"http://localhost:5028/api/Deep/GetMaterialpicAll",
        method:"get",
        params:{
            id:model.value.rId,
        }
    })
    .then(res=>{
        Materialpiclist.value=res.data.data;
    })
}

//深加工添加剂弹框
const Materiallogic= reactive({
  isopen:false,
})
//创建深加工添加剂请求
const createMaterial=()=>{
    axios({
        url:"http://localhost:5028/api/Deep/CreateMaterial",
        method:"post",
        data:Materialform
    })
    .then(res=>{
        if(res.data.code==100)
          {
              getMaterial();
              ElMessage.success(res.data.message);
              Materiallogic.isopen=false;
          }
          else{
              ElMessage.error(res.data.message);
          }
    })
}
//深加工添加剂表单
const Materialform = reactive({
  "materialId": 0,
  "rId": model.value.rId,
  "materialBath": ""
})

//深加工添加剂请求
const getMaterial=()=>{
  axios({
        url:"http://localhost:5028/api/Deep/GetMaterialAll",
        method:"get",
        params:{
            id:model.value.rId,
        }
    })
    .then(res=>{
        Materiallist.value=res.data.data;
    })
}
//深加添加剂料接收
const Materiallist=ref([{
  "materialId": 0,
  "rId": 0,
  "materialBath": ""
}])
//#endregion
//------------------------------------------------------------深加工辅料------------------------------------------------------------
//#region
//-------------深加工辅料----------------------------------------
//深加工辅料图片上传
const handleAvatarSuccessAdditivepic=(imageUrl:any)=>{
  Additivepicform.additiveImg=imageUrl;
  if(Additivepicform.additiveImg==null)
  {
    ElMessage.error("请上传图片");
    return;
  }
  axios({
          url:"http://localhost:5028/api/Deep/CreateAdditivepic",
          method:"post",
          data:Additivepicform
      })
      .then(res=>{
          if(res.data.code==100)
          {
              getAdditivepic();//食品安全图片请求
              ElMessage.success(res.data.message);
              Additivepicform.additiveImg="";
          }
          else{
              ElMessage.error(res.data.message);
          }
      })
}
//深加工辅料照片表单
const Additivepicform=reactive({
  "additivepicId": 0,
  "rId": model.value.rId,
  "additiveImg": ""
})

//深加工辅料照片接收
const Additivepiclist=ref([{
  "additivepicId": null,
  "rId": null,
  "additiveImg": ""
}])
//深加工辅料照片请求
const getAdditivepic=()=>{
    axios({
        url:"http://localhost:5028/api/Deep/GetAdditivepicAll",
        method:"get",
        params:{
            id:model.value.rId,
        }
    })
    .then(res=>{
        Additivepiclist.value=res.data.data;
    })
}

//深加工辅料弹框
const Additivelogic= reactive({
  isopen:false,
})
//创建深加工辅料请求
const createAdditive=()=>{
    axios({
        url:"http://localhost:5028/api/Deep/CreateAdditive",
        method:"post",
        data:Additiveform
    })
    .then(res=>{
        if(res.data.code==100)
          {
              getAdditive();
              ElMessage.success(res.data.message);
              Additivelogic.isopen=false;
          }
          else{
              ElMessage.error(res.data.message);
          }
    })
}
//深加工辅料表单
const Additiveform = reactive({
  "additiveId": 0,
  "rId": model.value.rId,
  "additiveBath": ""
})

//深加工辅料请求
const getAdditive=()=>{
  axios({
        url:"http://localhost:5028/api/Deep/GetAdditiveAll",
        method:"get",
        params:{
            id:model.value.rId,
        }
    })
    .then(res=>{
        Additivelist.value=res.data.data;
    })
}
//深加工辅料接收
const Additivelist=ref([{
  "additiveId": null,
  "rId": null,
  "additiveBath": ""
}])
//#endregion
//------------------------------------------------------------深加工原料----------------------------------------
//#region 
//深加工原料图片上传
const handleAvatarSuccessFeedstockpic=(imageUrl:any)=>{
  Feedstockpicform.feedstockImg=imageUrl;
  if(Feedstockpicform.feedstockImg==null)
  {
    ElMessage.error("请上传图片");
    return;
  }
  axios({
          url:"http://localhost:5028/api/Deep/CreateFeedstockpic",
          method:"post",
          data:Feedstockpicform
      })
      .then(res=>{
          if(res.data.code==100)
          {
              getFeedstockpic();//食品安全图片请求
              ElMessage.success(res.data.message);
              Feedstockpicform.feedstockImg="";
          }
          else{
              ElMessage.error(res.data.message);
          }
      })
}
//深加工原料照片表单
const Feedstockpicform=reactive({
  "feedstockpicId": 0,
  "rId": model.value.rId,
  "feedstockImg": ""
})

//深加工原料照片接收
const Feedstockpiclist=ref([{
  "feedstockId": null,
  "rId": null,
  "feedstockImg": ""
}])
//深加工原料照片请求
const getFeedstockpic=()=>{
    axios({
        url:"http://localhost:5028/api/Deep/GetFeedstockpicAll",
        method:"get",
        params:{
            id:model.value.rId,
        }
    })
    .then(res=>{
        Feedstockpiclist.value=res.data.data;
    })
}

//深加工原料弹框
const Feedstocklogic= reactive({
  isopen:false,
})
//创建深加工原料请求
const createFeedstock=()=>{
    axios({
        url:"http://localhost:5028/api/Deep/CreateFeedstock",
        method:"post",
        data:Feedstockform
    })
    .then(res=>{
        if(res.data.code==100)
          {
              getFeedstock();
              ElMessage.success(res.data.message);
              Feedstocklogic.isopen=false;
          }
          else{
              ElMessage.error(res.data.message);
          }
    })
}
//深加工原料表单
const Feedstockform = reactive({
  "feedstockId": 0,
  "rId": model.value.rId,
  "feedstockBath": ""
})

//深加工原料请求
const getFeedstock=()=>{
  axios({
        url:"http://localhost:5028/api/Deep/GetFeedstockAll",
        method:"get",
        params:{
            id:model.value.rId,
        }
    })
    .then(res=>{
        Feedstocklist.value=res.data.data;
    })
}
//深加工原料接收
const Feedstocklist=ref([{
  "feedstockId": null,
  "rId": null,
  "feedstockBath": ""
}])
//#endregion

//----------------------------------------------------------------------------
//食品安全图片上传
const handleAvatarSuccessdeeppic=(imageUrl:any)=>{
  deeppicform.foodSafetyImg=imageUrl;
  if(deeppicform.foodSafetyImg==null)
  {
    ElMessage.error("请上传图片");
    return;
  }
  axios({
          url:"http://localhost:5028/api/Deep/CreateFoodSafety",
          method:"post",
          data:deeppicform
      })
      .then(res=>{
          if(res.data.code==100)
          {
              getdeeppic();//食品安全图片请求
              ElMessage.success(res.data.message);
              deeppicform.foodSafetyImg="";
          }
          else{
              ElMessage.error(res.data.message);
          }
      })
}
//食品安全照片表单
const deeppicform=reactive({
  "foodSafetyId": 0,
  "rId": model.value.rId,
  "foodSafetyImg": ""
})

//食品安全照片接收
const deepppiclist=ref([{
  "foodSafetyId": null,
  "rId": null,
  "foodSafetyImg": ""
}])
//食品安全照片请求
const getdeeppic=()=>{
    axios({
        url:"http://localhost:5028/api/Deep/GetFoodSafetyAll",
        method:"get",
        params:{
            id:model.value.rId,
        }
    })
    .then(res=>{
        deepppiclist.value=res.data.data;
    })
}

//屠宰弹框
const deeplogic= reactive({
  isopen:false,
})
//创建屠宰信息请求
const createdeep=()=>{
    axios({
        url:"http://localhost:5028/api/Deep/CreateDeep",
        method:"post",
        data:deepform
    })
    .then(res=>{
        if(res.data.code==100)
          {
              getdeep();
              ElMessage.success(res.data.message);
              deeplogic.isopen=false;
          }
          else{
              ElMessage.error(res.data.message);
          }
    })
}
//屠宰表单
const deepform = reactive({
  "deepId": 0,
  "rId": model.value.rId,
  "deepClass": "",
  "deepPerson": ""
})

//屠宰企业信息请求
const getdeep=()=>{
  axios({
        url:"http://localhost:5028/api/Deep/GetDeepAll",
        method:"get",
        params:{
            id:model.value.rId,
        }
    })
    .then(res=>{
        deeplist.value=res.data.data;
    })
}
//屠宰企业信息接收
const deeplist=ref([{
  "deepId": 1,
  "rId": 20009,
  "deepClass": "生产1组",
  "deepPerson": "小陈"
}])
//---------------------------------------------------------屠宰-----------------------------------------------------------------------------

//屠宰企业图片上传
const handleAvatarSuccesscommpanypic=(imageUrl:any)=>{
  commpanypicform.commpanyPIcName=imageUrl;
  if(commpanypicform.commpanyPIcName==null)
  {
    ElMessage.error("请上传图片");
    return;
  }
  axios({
          url:"http://localhost:5028/api/Slaughter/CreateCommpanyPic",
          method:"post",
          data:commpanypicform
      })
      .then(res=>{
          if(res.data.code==100)
          {
              getcommpanypic();//屠宰公司图片请求
              ElMessage.success(res.data.message);
              commpanypicform.commpanyPIcName="";
          }
          else{
              ElMessage.error(res.data.message);
          }
      })
}
//屠宰企业照片表单
const commpanypicform=reactive({
  "commpanyPicId": 0,
  "rId": model.value.rId,
  "commpanyPIcName": ""
})

//屠宰企业照片接收
const commpanypiclist=ref([{
  "commpanyPicId": null,
  "rId": null,
  "commpanyPIcName": ""
}])
//屠宰企业照片请求
const getcommpanypic=()=>{
    axios({
        url:"http://localhost:5028/api/Slaughter/GetCommpanyPIcAll",
        method:"get",
        params:{
            id:model.value.rId,
        }
    })
    .then(res=>{
        commpanypiclist.value=res.data.data;
    })
}
//保存屠宰弹框信息
const savecommpany=()=>{
  if(commpanylogic.isadd==true)//添加
  {
    axios({
        url:"http://localhost:5028/api/Slaughter/CreateCommpany",
        method:"post",
        data:commpanyform
    })
    .then(res=>{
        if(res.data.code==100)
          {
              getcommpany();
              ElMessage.success(res.data.message);
              commpanylogic.isopen=false;
          }
          else{
              ElMessage.error(res.data.message);
          }
    })
  }else{//编辑
    axios({
        url:"http://localhost:5028/api/Slaughter/UpdateCommpany",
        method:"post",
        data:commpanyform
    })
    .then(res=>{
        if(res.data.code==100)
          {
              getcommpany();
              ElMessage.success(res.data.message);
              commpanylogic.isopen=false;
          }
          else{
              ElMessage.error(res.data.message);
          }
    })
  }
}
//打开屠宰企业弹框
const opencommpany=(row?:any)=>{
  commpanylogic.isopen=true;
  getprovincial();//调用省数据请求
  getcity();//调用市数据请求
  getaddress();//调用县数据请求
  if(row==null)
  {
      commpanylogic.isadd=true;
  }
  else{
    commpanylogic.isadd=false;
    commpanyform.commpanyId=row.commpanyId;
    commpanyform.commpanyName=row.commpanyName;
    commpanyform.createTime=moment(row.createTime).format("YYYY-MM-DD");
    commpanyform.commpanyAddress=row.commpanyAddress;
    commpanyform.commpanyDesc=row.commpanyDesc;
    cityform.CityId=row.cityId;
    cityform.ProvincialId=row.provincialId;
    console.log(cityform);
    console.log(commpanyform);
  }
}
//屠宰企业信息表单
const commpanyform=reactive({
  "commpanyId": 0,
  "rId": model.value.rId,
  "commpanyName": "",
  "createTime": "",
  "commpanyAddress": null,
  "commpanyDesc": ""
})
//屠宰企业弹框
const commpanylogic=reactive({
  isopen:false,
  isadd:false,
})
//------------------------------------------地区三级联动-------------------------------
//省市县三级联动查询条件
const cityform=reactive({
  ProvincialId:null,
  CityId:null,
})
//县城数据接收
const addresslist =ref([{
  "addressId": null,
  "addressName": "",
  "provincialId": null,
  "cityId": null
}])
//县城数据请求
const getaddress=()=>{
  axios({
        url:"http://localhost:5028/api/Address/GetAddressAll",
        method:"get",
        params:{ProvincialId:cityform.ProvincialId,CityId:cityform.CityId}
    })
    .then(res=>{
        addresslist.value=res.data.data;
    })
}
//市区数据接收
const citylist =ref([{
  "cityId": null,
  "cityName": "",
  "provincialId": null
}])
//市区数据请求
const getcity=()=>{
  axios({
        url:"http://localhost:5028/api/Address/GetCityAll",
        method:"get",
        params:{ProvincialId:cityform.ProvincialId}
    })
    .then(res=>{
        citylist.value=res.data.data;
        getaddress();
    })
}
//省会数据接收
const provinciallist =ref([{
  "provincialId": null,
  "provincialName": ""
}])
//省会数据请求
const getprovincial=()=>{
  axios({
        url:"http://localhost:5028/api/Address/GetProvincialAll",
        method:"get",
    })
    .then(res=>{
        provinciallist.value=res.data.data;
        getcity();
    })
}
//-------------------------------------------------------------------------------------
//屠宰企业信息请求
const getcommpany=()=>{
  axios({
        url:"http://localhost:5028/api/Slaughter/GetCommpanyAll",
        method:"get",
        params:{
            id:model.value.rId,
        }
    })
    .then(res=>{
        commpanylist.value=res.data.data;
    })
}
//屠宰企业信息接收
const commpanylist=ref([{
  "commpanyId": 1,
  "rId": 20009,
  "commpanyName": "杭州杨云公司",
  "createTime": "2020-02-23T00:00:00",
  "commpanyAddress": 1,
  "commpanyDesc": "地方GV"
}])
//屠宰相关资质表单
const qualificationform=reactive({
  "qualificationId": 0,
  "rId": model.value.rId,
  "qualificationImg": ""
})
//屠宰相关资质图片上传
const handleAvatarSuccessqualification=(imageUrl:any)=>{
  qualificationform.qualificationImg=imageUrl;
  if(qualificationform.qualificationImg==null)
  {
    ElMessage.error("请上传图片");
    return;
  }
  axios({
          url:"http://localhost:5028/api/Slaughter/CreateQualification",
          method:"post",
          data:qualificationform
      })
      .then(res=>{
          if(res.data.code==100)
          {
              getqualification();//屠宰资质信息请求
              ElMessage.success(res.data.message);
              qualificationform.qualificationImg="";
          }
          else{
              ElMessage.error(res.data.message);
          }
      })
}
//屠宰资质信息接收
const qualificationlist=ref([{
  "qualificationId": 1,
  "rId": 20009,
  "qualificationImg": "http://localhost:5028/pic/2.png"
}])
//屠宰资质信息请求
const getqualification=()=>{
  axios({
        url:"http://localhost:5028/api/Slaughter/GetQualificationAll",
        method:"get",
        params:{
            id:model.value.rId,
        }
    })
    .then(res=>{
        qualificationlist.value=res.data.data;
    })
}
//屠宰弹框
const slautherlogic= reactive({
  isopen:false,
})
//创建屠宰信息请求
const createslauther=()=>{
    axios({
        url:"http://localhost:5028/api/Slaughter/CreateSlaughter",
        method:"post",
        data:slauhterform
    })
    .then(res=>{
        if(res.data.code==100)
          {
              getSlaughter();
              ElMessage.success(res.data.message);
              slautherlogic.isopen=false;
          }
          else{
              ElMessage.error(res.data.message);
          }
    })
}
//屠宰表单
const slauhterform = reactive({
  "slaughterId": 0,
  "rId": model.value.rId,
  "slaughterbatch": null,
  "slaughterweight": null,
  "arrivateTime": "",
  "slaughterTime": ""
})
//屠宰数据接收
const Slaughterlist = ref([{
  "slaughterId": 0,
  "rId": null,
  "slaughterbatch": null,
  "slaughterweight": null,
  "arrivateTime": "",
  "slaughterTime": ""
}])
//获取屠宰数据
const getSlaughter=()=>{
  axios({
        url:"http://localhost:5028/api/Slaughter/GetEnterpriseAll",
        method:"get",
        params:{
            id:model.value.rId,
        }
    })
    .then(res=>{
        Slaughterlist.value=res.data.data;
    })
}
//---------------------------------------------------------养殖-----------------------------------------------------------------------------
//养殖公司图片表单
const quarantineform =reactive({
  "enterprisePicId": 0,
  "rId": model.value.rId,
  "enterprisePicName": ""
})
//养殖公司图片上传
const handleAvatarSuccessquarantine=(imageUrl:any)=>{
  quarantineform.enterprisePicName=imageUrl;
  if(quarantineform.enterprisePicName==null)
  {
    ElMessage.error("请上传图片");
    return;
  }
  axios({
          url:"http://localhost:5028/api/Enterprise/CreateEnterprisepic",
          method:"post",
          data:quarantineform
      })
      .then(res=>{
          if(res.data.code==100)
          {
              getquarantinepic();
              ElMessage.success(res.data.message);
              quarantineform.enterprisePicName="";
          }
          else{
              ElMessage.error(res.data.message);
          }
      })
}
//养殖公司图片数据
const quarantinelistpic = ref([{
  enterprisePicId: 0,
  rId: 0,
  enterprisePicName: ""
}])
//获取养殖公司图片数据
const getquarantinepic=()=>{
  axios({
        url:"http://localhost:5028/api/Enterprise/GetEnterprisepicAll",
        method:"get",
        params:{
            id:model.value.rId,
        }
    })
    .then(res=>{
        quarantinelistpic.value=res.data.data;
        
    })
}
//--------------------------------------------------------
//保存养殖养殖企业信息
const saveEnterprise=()=>{
  axios({
        url:"http://localhost:5028/api/Enterprise/CreateEnterprise",
        method:"post",
        data:enterpriseform
    })
    .then(res=>{
        if(res.data.code==100)
          {
              getenterprisize();
              ElMessage.success(res.data.message);
              enterpriselogic.isopen=false;
          }
          else{
              ElMessage.error(res.data.message);
          }
    })
}
//养殖企业表单
const enterpriseform =reactive({
  "enterpriseId": 0,
  "rId": model.value.rId,
  "enterpriseFarm": "",
  "enterprisePerson": "",
  "inventotyNumber": null,
})
//养殖企业弹框
const enterpriselogic=reactive({
  isopen:false,
})
//养殖企业信息
const enterprisizelist=ref([])
//养殖企业信息请求
const getenterprisize =()=>{
  axios({
        url:"http://localhost:5028/api/Enterprise/GetEnterpriseAll",
        method:"get",
        params:{
            id:model.value.rId,
        }
    })
    .then(res=>{
        enterprisizelist.value=res.data.data;
        
    })
}
//动检证表单
const enterprisepicform =reactive({
  "quarantineId": 0,
  "rId": model.value.rId,
  "quarantineImg": ""
})
//动检证图片上传
const handleAvatarSuccess=(imageUrl:any)=>{
  enterprisepicform.quarantineImg=imageUrl;
  if(enterprisepicform.quarantineImg==null)
  {
    ElMessage.error("请上传图片");
    return;
  }
  axios({
          url:"http://localhost:5028/api/Enterprise/CreateQuarantine",
          method:"post",
          data:enterprisepicform
      })
      .then(res=>{
          if(res.data.code==100)
          {
              getenterprisizepic();
              ElMessage.success(res.data.message);
              enterprisepicform.quarantineImg="";
          }
          else{
              ElMessage.error(res.data.message);
          }
      })
}
//单图片上传验证
const beforeAvatarUpload: UploadProps['beforeUpload'] = (rawFile) => {
  if (rawFile.size / 1024 / 1024 > 2) {
    ElMessage.error('大小不得超过2MB!')
    return false
  }
  return true
}
//动检证数据
const enterprisizelistpic = ref([{
  "quarantineId": null,
  "rId": null,
  "quarantineImg": ""
}])
//获取动检证数据
const getenterprisizepic=()=>{
  axios({
        url:"http://localhost:5028/api/Enterprise/GetQuarantineAll",
        method:"get",
        params:{
            id:model.value.rId,
        }
    })
    .then(res=>{
        enterprisizelistpic.value=res.data.data;
        
    })
}
//----------------------------------------多图片上传--------------------------------------
import { Plus } from '@element-plus/icons-vue'
import type { UploadProps, UploadUserFile } from 'element-plus'
const fileList = ref<UploadUserFile[]>([ ])
const dialogImageUrl = ref('')
const dialogVisible = ref(false)
const handleRemove: UploadProps['onRemove'] = (uploadFile, uploadFiles) => {
  console.log(uploadFile, uploadFiles)
}
const handlePictureCardPreview: UploadProps['onPreview'] = (uploadFile) => {
  dialogImageUrl.value = uploadFile.url!
  dialogVisible.value = true
}
//------------------------------免疫信息-----------------------------------
//免疫弹框
const logicImmunity=reactive({
  isopen:false,
})
//打开免疫弹框
const openimmunity=(row:any)=>{
  logicImmunity.isopen=true;
  ImmunityForm.immunityId=row.immunityId;
  ImmunityForm.immunityMethod=row.immunityMethod;
  ImmunityForm.immunityType=row.immunityType;
  ImmunityForm.raiseDay=row.raiseDay;
}
//删除免疫信息请求
const deleteImmunity=(id:any)=>{
  ElMessageBox.confirm(
    '确认删除该条免疫信息吗?',
    '警告',
    {
      confirmButtonText: '确认',
      cancelButtonText: '取消',
      type: 'warning',
    }
  )
    .then(() => {
        axios({
            url:"http://localhost:5028/api/Breed/DeleteImmunity",
            method:"put",
            params:{
              id:id
            }
        })
        .then(res=>{
            if(res.data.code==100)
              {
                  getImmunity();
                  ElMessage.success(res.data.message);
              }
              else{
                  ElMessage.error(res.data.message);
              }
        })
    })
    .catch(() => {
      ElMessage({
        type: 'info',
        message: '已取消',
      })
    })
  
}
//修改免疫信息请求
const updateImmunity=()=>{
  axios({
        url:"http://localhost:5028/api/Breed/UopdateImmunity",
        method:"post",
        data:ImmunityForm
    })
    .then(res=>{
        if(res.data.code==100)
          {
              getImmunity();
              ElMessage.success(res.data.message);
              logicImmunity.isopen=false;
          }
          else{
              ElMessage.error(res.data.message);
          }
    })
}
//免息信息添加表单
const ImmunityForm=reactive({
  immunityId:0,
  rId: model.value.rId,
  raiseDay: null,
  immunityType: "",
  immunityMethod: ""
})
//保存免疫信息请求
const saveImmunity=(row:any)=>{
  ImmunityForm.raiseDay=row.raiseDay;
  ImmunityForm.immunityType=row.immunityType;
  ImmunityForm.immunityMethod=row.immunityMethod;
  axios({
        url:"http://localhost:5028/api/Breed/CreateImmunity",
        method:"post",
        data:ImmunityForm
    })
    .then(res=>{
        if(res.data.code==100)
          {
              getImmunity();
              ElMessage.success(res.data.message);
          }
          else{
              ElMessage.error(res.data.message);
          }
    })
}
//移除一行免疫信息
const removeimmunity=(index:any)=>{
  ImmunitytableData.value.splice(index,1)
}
//新增一行免疫信息
const createimmunity=()=>{
  ImmunitytableData.value.push({
    immunityId: null,
    rId: null,
    raiseDay: null,
    immunityType: "",
    immunityMethod: "",
    isDel: false
  })
}
//免疫信息接收
const ImmunitytableData=ref([{
  immunityId: null,
  rId: null,
  raiseDay: null,
  immunityType: "",
  immunityMethod: "",
  isDel: false
}])

//免疫信息请求
const getImmunity=()=>{
  axios({
        url:"http://localhost:5028/api/Breed/GetImmunityAll",
        method:"get",
        params:{
            id:model.value.rId,
        }
    })
    .then(res=>{
        ImmunitytableData.value=res.data.data;
        
    })
}
//------------------------------保存/打开养殖弹框-----------------------------------
//打开养殖弹框
const openbreed=(row?:any)=>{
  Breedform.breedVariety="";
  Breedform.breedRaise="";
  Breedform.raiseDay=null;
  Breedform.raiseBrand="";
  Breedform.breedRaiser="";
  Breedform.endTime="";
  breedlogic.isopen=true;
  console.log(row);
  
  if(row==null)
  {
    breedlogic.isadd=true;
  }
  else
  {
    breedlogic.isadd=false;
    Breedform.rId=row.rId;
    Breedform.breedId=row.breedId;
    Breedform.breedVariety=row.breedVariety;
    Breedform.breedRaise=row.breedRaise;
    Breedform.raiseDay=row.raiseDay;
    Breedform.raiseBrand=row.raiseBrand;
    Breedform.breedRaiser=row.breedRaiser;
    Breedform.endTime=moment(row.endTime).format('YYYY-MM-DD');
  }
}
//养殖弹框
const breedlogic=reactive({
  isopen:false,
  isadd:false,
})
//保存养殖弹框信息
const savebreed=()=>{ 
  debugger
  if(breedlogic.isadd==true)//添加
  {
      axios({
          url:"http://localhost:5028/api/Breed/CreateBreed",
          method:"post",
          data:Breedform
      })
      .then(res=>{
          
          if(res.data.code==100)
          {
              GetBreeding();
              breedlogic.isopen=false;
              ElMessage.success(res.data.message);
              
          }
          else{
              ElMessage.error(res.data.message);
          }
      })
  }
  else{//修改
      axios({
          url:"http://localhost:5028/api/Breed/UpdateBreed",
          method:"post",
          data:Breedform
      })
      .then(res=>{
          
          if(res.data.code==100)
          {
              GetBreeding();
              breedlogic.isopen=false;
              ElMessage.success(res.data.message);
              
          }
          else{
              ElMessage.error(res.data.message);
          }
      })
  }
}
//-----------------------------养殖表获取----------------------------------------
//养殖数据请求
const GetBreeding=()=>{
    axios({
        url:"http://localhost:5028/api/Breed/GetBreedAll",
        method:"get",
        params:{
            id:model.value.rId,
        }
    })
    .then(res=>{
        BreedtableData.value=res.data.data;
        
    })
}
//养殖表数据接收
const BreedtableData = ref([])
//-----------------------------标签页----------------------------------------
import type { TabsPaneContext } from 'element-plus'
const activeName = ref('first')
const handleClick = (tab: TabsPaneContext, event: Event) => {
  console.log(tab, event)
}
//------------------------------------------------------------------------
//养殖信息表单
const Breedform=reactive({
  breedId: 0,
  rId: model.value.rId,
  raiseDay:null,
  breedVariety: "",
  breedRaise: "",
  raiseBrand: "",
  breedRaiser: "",
  endTime: ""
})
onMounted(()=>{
    GetBreeding();//调用养殖信息请求
    getImmunity();//调用免疫信息请求
    getenterprisize();//调用企业信息请求
    getenterprisizepic();//调用动检证信息请求
    getquarantinepic();//调用企业图片请求
    getSlaughter();//调用屠宰信息请求
    getqualification();//屠宰相关资质请求
    getcommpany();//屠宰企业信息请求
    getcommpanypic();//屠宰企业图片请求
    getdeep();//深加工信息请求
    getdeeppic();//深加工图片请求
    getFeedstock();//深加工原料请求
    getFeedstockpic();//深加工原料图片请求
    getAdditive();//深加工辅料信息请求
    getAdditivepic();//深加工辅料图片请求
    getMaterial();//深加工添加剂请求
    getMaterialpic();//深加工添加剂图片请求
    getPackaging();//深加工包材请求
    getPackagingpic();//深加工包材图片请求
    getProcessingCommpany();//深加企业请求
    getProcessingpic();//深加企业图片请求
})
</script>
<style>
.el-upload--picture-card {
    width: 80px;
    /* 自定义宽度 */
    height: 80px;
    /* 自定义高度 */
}
/* 调整卡片内图标的大小（若需要） */
.el-upload--picture-card .el-icon-plus {
    font-size: 10px;
    width: 80px;
    height: 80px;
    /* 图标字号 */
}
.avatar-uploader .el-upload {
  border: 1px dashed var(--el-border-color);
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: var(--el-transition-duration-fast);
}
.avatar-uploader .el-upload:hover {
  border-color: var(--el-color-primary);
}
.el-icon.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 100px;
  height: 100px;
  text-align: center;
}
</style>
<style scoped>
.avatar-uploader .avatar {
  width: 100px;
  height: 100px;
  display: block;
}
</style>